About 644 letters
About 3 minutes
Description: Executes an expression and returns the result.
def eval(source: str | codeobject, /, globals: dict = None, locals: mapping = None):
'''
Executes an expression and returns the result
:param source: A Python expression
:param globals: Global namespace
:param locals: Local namespace
:return: The result of the expression evaluation
'''
Example:
print(eval('1 + 1'))
x = 233
print(eval('x + 1'))
Created in 5/15/2025
Updated in 5/16/2025